package api

import (
	"voice_chat_room/internal/service"
	"voice_chat_room/pkg/response"

	"github.com/gin-gonic/gin"
)

func Register(c *gin.Context) {
	var req service.RegisterReq
	if err := c.ShouldBindJSON(&req); err != nil {
		c.JSON(200, response.BadRequest("参数错误", err))
		return
	}
	resp := req.Register(c)
	c.JSON(200, resp)
}

func Login(c *gin.Context) {
	var req service.LoginReq
	if err := c.ShouldBindJSON(&req); err != nil {
		c.JSON(200, response.BadRequest("参数错误", err))
		return
	}
	resp := req.Login(c)
	c.JSON(200, resp)
}

// ChangePassword 修改密码
func ChangePassword(c *gin.Context) {
	var req service.ChangePasswordReq
	if err := c.ShouldBindJSON(&req); err != nil {
		c.JSON(200, response.BadRequest("参数错误", err))
		return
	}
	resp := req.ChangePassword(c)
	c.JSON(200, resp)
}
